<template>
  <div class="login">
    <input type="text" v-model="username" placeholder="请输入用户名" />
    <van-button type="warning" @click="loginHandler" class="login-btn"
      >登录</van-button
    >
  </div>
</template>

<script>
import { mapActions } from "vuex";
import { loginApi } from "../../https/userApi";

export default {
  name: "LoginView",
  data() {
    return {
      username: "",
    };
  },
  methods: {
    ...mapActions(["user/loginAction"]),
    ...mapActions({
      login: "user/loginAction",
    }),
    loginHandler() {
      loginApi("admin", "123")
        .then((res) => {
          console.log("登陆成功：", res);
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.login-btn {
  width: 750px;
}
</style>